#include "Animation.h"

#include <windows.h>    // include the basic windows header file
#include <windowsx.h>

Animation::Animation()
{

}

void Animation::Init( ISprite* sprite, int numFrames, int duration )
{
	m_sprite = sprite;
	m_numFrames = numFrames;
	m_duration = duration;
}


void Animation::StartAnimation( double time )
{
	m_startTime = time;
}

void Animation::Draw( double time, float rotation, float xPos, float yPos, bool flipped )
{
	double elapsedTime( time - m_startTime );
	int timesRun( elapsedTime / m_duration);
	elapsedTime -= timesRun * m_duration;
	int timePerFrame( m_duration / m_numFrames );

	int frame( ( elapsedTime / timePerFrame ) );
	//int frame( (int)frameTime % m_numFrames );
	
	m_sprite->Draw( frame, rotation, xPos, yPos, flipped );

}
